﻿#include "Example.h"
using namespace std;
using namespace ASL;

// 3.1 线性代数运算案例
void Example::Example1(void)
{
    cout << "------ 3.1 线性代数运算案例 ------" << endl
         << endl;

    // 创建指定维度矩阵对象
    Matrix A(5, 5), B, H;

    // 通过函数运算符访问指定行列元素
    A(0, 0) = 0.8147;
    A(0, 1) = 0.0975;
    A(0, 2) = 0.1576;
    A(0, 3) = 0.1419;
    A(0, 4) = 0.6557;
    A(1, 0) = 0.9058;
    A(1, 1) = 0.2785;
    A(1, 2) = 0.9706;
    A(1, 3) = 0.4218;
    A(1, 4) = 0.0357;
    A(2, 0) = 0.1270;
    A(2, 1) = 0.5469;
    A(2, 2) = 0.9572;
    A(2, 3) = 0.9157;
    A(2, 4) = 0.8491;
    A(3, 0) = 0.9134;
    A(3, 1) = 0.9575;
    A(3, 2) = 0.4854;
    A(3, 3) = 0.7922;
    A(3, 4) = 0.9340;
    A(4, 0) = 0.6324;
    A(4, 1) = 0.9649;
    A(4, 2) = 0.8003;
    A(4, 3) = 0.9595;
    A(4, 4) = 0.6787;
    cout << "Matrix A" << endl;
    cout << A << endl;

    // 矩阵基本运算 H = (A+2*A^T)*A*|A|
    cout << "Matrix (A+2*A^T)*A*|A|" << endl;
    H = (A + Matrix::transpose(A) * 2.0) * A * Matrix::determinant(A);
    cout << H << endl;

    // 矩阵求逆运算 H = A^-1
    cout << "Matrix A^-1" << endl;
    H = Matrix::inverse(A);
    cout << H << endl;

    // 矩阵正交分解 A = Q*R
    Matrix Q, R;

    Matrix::householderQR(A, Q, R);

    cout << "Matrix Q" << endl;
    cout << Q << endl;
    cout << "Matrix R" << endl;
    cout << R << endl;

    // 矩阵三角分解 A = L*U
    Matrix L, U;

    Matrix::gaussLU(A, L, U);

    cout << "Matrix L" << endl;
    cout << L << endl;
    cout << "Matrix U" << endl;
    cout << U << endl;

    // 矩阵特征值求解 A*X = Lamda*X
    vector<complex<double>> E;

    E = Matrix::eigenValue(A);

    cout << "Matrix Eigen" << endl;

    for (int n = 0; n < E.size(); n++)
    {
        Basic::display(cout, E[n]);
        cout << endl;
    }

    cout << endl;
}

// 3.2 数值积分求解案例
void Example::Example2(void)
{
    cout << "------ 3.2 数值积分求解案例 ------" << endl
         << endl;

    // 创建积分器对象
    Calculus A;

    // 初始化积分器配置
    // 计算模式 数值积分模式
    // 积分初值 0.0
    // 计算步长 0.005 s
    // 积分方法 欧拉法 ODE-1
    A.initialize(Calculus::Integrator, Calculus::Euler, 0.005, 0.0);

    // 设置积分限幅
    // 是否启用限幅功能 true/false
    // 设置计算限幅值域 -0.5~+0.5
    A.limit(false);
    A.limit(-0.5, 0.5);

    // 模拟计算时序循环
    for (int n = 0; n < 100; n++)
    {
        double t, u, y;

        // 更新仿真时刻 t(n+1)=t(n)+0.005
        t = n * 0.005;

        // 待积分函数信号 f(x)=sin(2*PI*t)
        u = sin(t * 2.0 * PI);

        // 执行积分器的单步计算函数 返回当前周期计算结果
        y = A.calculate(u);

        // 访问积分器历史计算存储容器
        // 访问对象 0阶数值序列
        // 访问周期 前1个计算周期
        y = A.value(Calculus::X, 1);

        // 访问积分器历史计算存储容器
        // 访问对象 1阶数值序列
        // 访问周期 前1个计算周期
        y = A.value(Calculus::XDot, 1);
    }
}

// 3.3 多维线性插值计算案例
void Example::Example3(void)
{
    cout << "------ 3.3 多维线性插值计算案例 ------" << endl
         << endl;

    // 通过数组定义插值数据序列
    // 插值数轴X alpha = [0, 2]
    // 插值数轴X beta = [-2, -1, 0, 1, 2]
    // 插值数轴Y gamma = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    // 函数关系 gamma = f(alpha, beta)
    double alpha[2] = {0, 2};
    double beta[5] = {-2, -1, 0, 1, 2};
    double gamma[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    double value;
    bool ok;

    // 使用静态公有函数直接进行插值计算
    value = LookupTable::interp(2, 5, alpha, beta, gamma, 2, 0, false);

    // 创建数据插值表对象
    LookupTable A, B;

    // 使用预设数组设置线性插值表对象数据内容
    A.initialize(2, alpha, 5, beta, 10, gamma);
    cout << "LookupTable A" << endl;
    cout << A << endl;

    // 将线性插值表对象存储为标准格式的本地数据文件
    A.save("Example3.txt");

    // 读取外部数据文件以初始化线性插值表对象
    ok = B.load("Example3.txt");
    cout << "LookupTable B" << endl;
    cout << B << endl;

    // 使用线性插值表的公有函数进行线性插值计算
    value = B.interp(0, 1, false);
}

// 3.4 线性系统分析案例
void Example::Example4(void)
{
    cout << "------ 3.4 线性系统分析案例 ------" << endl
         << endl;

    // 数据记录文件
    ofstream stream;

    // 参考系统结构框图
    // u -->x--> D --> A --> G --.--> y
    //     -^                |
    //      |------ H -------|

    // 创建系统环节传递函数
    Polynomial num, den;
    TransferFunction D, A, G, H;

    num = Polynomial{100.0};
    den = Polynomial{0.0, 5.0, 1.0};
    G = TransferFunction(num, den);

    num = Polynomial{1.0};
    den = Polynomial{1.0, 0.005};
    A = TransferFunction(num, den);

    num = Polynomial{1.0, 0.2};
    den = Polynomial{1.0, 0.02};
    D = TransferFunction(num, den);

    num = Polynomial{1.0};
    den = Polynomial{1.0};
    H = TransferFunction(num, den);

    // 计算系统开环传递函数
    TransferFunction G_OPEN;

    G_OPEN = D * A * G;

    cout << "开环传递函数 G-Open" << endl
         << endl;
    cout << G_OPEN << endl;

    // 计算开环传递函数的零极点
    TransferFunction::ZeroPole S_ZPK;

    S_ZPK = TransferFunction::zeroPole(G_OPEN);

    cout << "系统零点 Zero" << endl;

    for (int n = 0; n < S_ZPK.zero.size(); n++)
    {
        Basic::display(cout, S_ZPK.zero[n]);
        cout << endl;
    }

    cout << endl;

    cout << "系统极点 Pole" << endl;

    for (int n = 0; n < S_ZPK.pole.size(); n++)
    {
        Basic::display(cout, S_ZPK.pole[n]);
        cout << endl;
    }

    cout << endl;

    cout << "系统增益 K" << endl;
    cout << S_ZPK.k << endl;
    cout << endl;

    // 计算开环传递函数的对数频率特性
    vector<double> omega, phase, gain;

    // 计算自定义频率序列 [0.01, 0.1, 1, 10, 100] rad/s 的对数频率特性
    omega = vector<double>{0.01, 0.1, 1, 10, 100};
    TransferFunction::bode(G_OPEN, omega, gain, phase);

    // 默认计算 0.01~100 rad/s 频率区间的对数频率特性
    omega.clear();
    TransferFunction::bode(G_OPEN, omega, gain, phase);

    // 记录仿真结果
    stream.open("Example4A.txt");
    stream << "Omega(rad/s)\tGain(dB)\tPhase(deg)" << endl;

    for (int n = 0; n < omega.size(); n++)
    {
        stream << omega[n] << "\t" << gain[n] << "\t" << phase[n] << endl;
    }

    stream.close();

    // 计算开环传递函数的幅值/相位裕度
    TransferFunction::Margin S_MARGIN;

    // 计算幅值/相位裕度
    S_MARGIN = TransferFunction::margin(omega, gain, phase);

    cout << "稳定裕度指标 Margin" << endl;
    cout << "Gm(dB)\t" << S_MARGIN.Gm << endl;
    cout << "Pm(deg)\t" << S_MARGIN.Pm << endl;
    cout << "Wcg(rad/s)\t" << S_MARGIN.Wcg << endl;
    cout << "Wcp(rad/s)\t" << S_MARGIN.Wcp << endl;
    cout << endl;

    // 计算系统闭环传递函数
    TransferFunction G_CLOSE;

    G_CLOSE = TransferFunction::feedback(D * A * G, H);

    cout << "闭环传递函数 G-Close" << endl
         << endl;
    cout << G_CLOSE << endl;

    // 计算闭环传递函数的阶跃响应
    vector<double> time, value;

    // 计算自定义时间区间 0:0.01:5s 的单位阶跃响应
    TransferFunction::step(G_CLOSE, time, value, 0.01, 5.0);

    // 默认计算 0:0.005:10s 时间区间的单位阶跃响应
    TransferFunction::step(G_CLOSE, time, value);

    // 记录仿真结果
    stream.open("Example4B.txt");
    stream << "Time(s)\tValue(-)" << endl;

    for (int n = 0; n < time.size(); n++)
    {
        stream << time[n] << "\t" << value[n] << endl;
    }

    stream.close();

    // 计算系统的时域性能指标
    TransferFunction::Step S_STEP;

    S_STEP = TransferFunction::step(time, value);

    cout << "动态性能指标 Step" << endl;
    cout << "RiseTime(s)\t" << S_STEP.riseTime << endl;
    cout << "PeakTime(s)\t" << S_STEP.peakTime << endl;
    cout << "SettingTime(s)\t" << S_STEP.settingTime << endl;
    cout << "PeakValue(-)\t" << S_STEP.peakValue << endl;
    cout << "FinalValue(-)\t" << S_STEP.finalValue << endl;
    cout << "OverShoot(-)\t" << S_STEP.overShoot << endl;
    cout << endl;

    // 计算闭环传递函数的离散化形式 T = 0.005 s
    TransferFunction G_DISC;

    G_DISC = TransferFunction::discrete(G_CLOSE, 0.005);

    cout << "离散传递函数 G-Discrete" << endl
         << endl;
    cout << G_DISC << endl;

    // 记录仿真结果
    stream.open("Example4C.txt");
    stream << "Time(s)\tValue(-)" << endl;

    // 模拟仿真计算周期循环
    for (int n = 0; n < 2000; n++)
    {
        double t, u, y;

        // 更新仿真时间 t(n+1)=t(n)+0.005
        t = n * 0.005;

        // 模拟单位阶跃输入
        u = 1.0;

        // 计算离散传递函数的时序输出
        y = G_DISC.response(u);

        // 打印时序计算结果
        stream << t << "\t" << y << endl;
    }

    stream.close();
}

// 3.5 坐标系算法案例
void Example::Example5(void)
{
    cout << "------ 3.5 坐标系算法案例 ------" << endl
         << endl;

    // 计算坐标系旋转矩阵
    // 绕X轴旋转 30 deg
    Matrix A;

    A = Coordinate::rotationX(30.0);

    // 计算坐标系投影矩阵
    // 旋转关系 导航系 > 机体系
    // 滚动角 0.0 deg  航向角 0.0 deg 俯仰角 30.0 deg
    A = Coordinate::cNav2Body(0.0, 0.0, 30.0);

    // 计算导航系速度向量在机体系投影 [10.0, 0.0, 0.0] m/s
    Vector vN(3), vB(3);

    vN(AXIS_N) = 10.0;
    vN(AXIS_U) = 0.0;
    vN(AXIS_E) = 0.0;

    vB = A * vN;

    // 计算欧拉角 [gamma, psi, zeta] deg
    // 坐标轴旋转顺序 Y-Z-X
    Vector eular(3);

    eular = Coordinate::eular(A, Coordinate::YZX);

    // 计算四元数 [q0, q1, q2, q3]
    Vector Q(4);

    Q = Coordinate::quaternion(A);

    // 计算攻角/侧滑角 deg
    double alpha, beta;

    alpha = Coordinate::alpha(vB(AXIS_X), vB(AXIS_Y), vB(AXIS_Z));
    beta = Coordinate::beta(vB(AXIS_X), vB(AXIS_Y), vB(AXIS_Z));

    // 计算弹道倾角/弹道偏角 deg
    double theta, psiV;

    theta = Coordinate::theta(vN(AXIS_N), vN(AXIS_U), vN(AXIS_E));
    psiV = Coordinate::psiV(vN(AXIS_N), vN(AXIS_U), vN(AXIS_E));
}

// 3.6 地球几何算法案例
void Example::Example6(void)
{
    cout << "------ 3.6 地球几何算法案例 ------" << endl
         << endl;

    // 计算指定纬度 deg 位置的曲率半径 m
    double Rm, Rn;

    Rm = Geodesy::radiusM(39.0);
    Rn = Geodesy::radiusN(39.0);

    // 计算指定纬度 deg 和 海拔高度 m 位置的重力加速度 m/s^2
    double g;

    g = Geodesy::gravity(39.0, 0.0);

    // 计算 A 至 B 的 大地距离 m 和 方位角 deg
    double S, A;
    double longitudeA = 122.0, latitudeA = 39.0;
    double longitudeB = 122.05, latitudeB = 39.05;

    Geodesy::vincentSA(longitudeA, latitudeA, longitudeB, latitudeB, S, A);

    // 换算 地心地固系坐标 ECEF 与 经纬高 LLA
    Vector ECEF(3), LLA(3);

    LLA(AXIS_LON) = 122.0;
    LLA(AXIS_LAT) = 39.0;
    LLA(AXIS_ALT) = 0.0;

    ECEF = Geodesy::cLLA2ECEF(LLA(AXIS_LON), LLA(AXIS_LAT), LLA(AXIS_ALT));
    LLA = Geodesy::cECEF2LLA(ECEF(AXIS_X), ECEF(AXIS_Y), ECEF(AXIS_Z));
}

// 5.7 经典控制器设计案例
void Example::Example7(void)
{
    cout << "------ 5.7 经典控制器设计案例 ------" << endl
         << endl;

    // 数据记录文件
    ofstream stream;

    // 控制参数
    double Kp = 12.0, Ki = 1.0, Kd = 5.0;

    // 创建环节传递函数
    Polynomial num, den;
    TransferFunction G, PID;

    num = Polynomial{1.0};
    den = Polynomial{0.0, 5.0, 6.0, 1.0};
    G = TransferFunction(num, den);

    num = Polynomial{Ki, Kp, Kd};
    den = Polynomial{0.0, 1.0};
    PID = TransferFunction(num, den);

    // 计算系统闭环传递函数
    TransferFunction Gc;

    Gc = TransferFunction::feedback(PID * G, 1.0);

    cout << "闭环传递函数 Gc" << endl
         << endl;
    cout << Gc << endl;

    // 计算闭环传递函数的离散化形式 采样时间 0.005 s
    TransferFunction Gz;

    Gz = TransferFunction::discrete(Gc, 0.005);

    cout << "离散传递函数 Gz" << endl
         << endl;
    cout << Gz << endl;

    // 记录仿真结果
    stream.open("Example7.txt");
    stream << "Time(s)\tU(-)\tY(-)" << endl;

    // 模拟仿真计算周期循环 0 ~ 10s
    for (int n = 0; n < 2000; n++)
    {
        double t, u, y;

        // 更新仿真时间 t(n+1)=t(n)+0.005
        t = n * 0.005;

        // 模拟单位阶跃输入
        u = 1.0;

        // 计算离散传递函数的时序输出
        y = Gz.response(u);

        // 打印时序计算结果
        stream << t << "\t" << u << "\t" << y << endl;
    }

    stream.close();
    cout << endl;
}

// 5.8 控制系统时域分析案例
void Example::Example8(void)
{
    cout << "------ 5.8 控制系统时域分析案例 ------" << endl
         << endl;

    // 数据记录文件
    ofstream stream;

    // 待研究系统参数
    double Kp = 2.0;
    double Ta = 0.1;

    // 创建分子/分母多项式
    Polynomial num, den;

    num = Polynomial{Kp};
    den = Polynomial{Kp, 1.0, Ta};

    // 创建系统闭环传递函数
    TransferFunction Gc;

    Gc = TransferFunction(num, den);

    cout << "闭环传递函数 Gc" << endl
         << endl;
    cout << Gc << endl;

    // 计算闭环传递函数的单位阶跃响应
    vector<double> time, value;

    // 自定义时域区间 0:0.005:5s
    TransferFunction::step(Gc, time, value, 0.005, 5.0);

    // 记录仿真结果
    stream.open("Example8.txt");
    stream << "Time(s)\tValue(-)" << endl;

    for (int n = 0; n < time.size(); n++)
    {
        stream << time[n] << "\t" << value[n] << endl;
    }

    stream.close();

    // 计算系统的时域性能指标
    TransferFunction::Step ST;

    ST = TransferFunction::step(time, value);

    cout << "动态性能指标 Step" << endl;
    cout << "RiseTime(s)\t" << ST.riseTime << endl;
    cout << "PeakTime(s)\t" << ST.peakTime << endl;
    cout << "SettingTime(s)\t" << ST.settingTime << endl;
    cout << "PeakValue(-)\t" << ST.peakValue << endl;
    cout << "FinalValue(-)\t" << ST.finalValue << endl;
    cout << "OverShoot(-)\t" << ST.overShoot << endl;
    cout << endl;
}

// 5.10 控制系统频域分析案例
void Example::Example9(void)
{
    cout << "------ 5.10 控制系统频域分析案例 ------" << endl
         << endl;

    // 数据记录文件
    ofstream stream;

    // 待研究系统参数
    double Kp = 2.0;
    double Ta = 0.1;

    // 创建分子/分母多项式
    Polynomial num, den;

    num = Polynomial{Kp};
    den = Polynomial{1.0, Ta};

    // 创建系统开环传递函数
    TransferFunction Go;

    Go = TransferFunction(num, den);

    cout << "开环传递函数 Go" << endl
         << endl;
    cout << Go << endl;

    // 记录仿真结果
    stream.open("Example9A.txt");
    stream << "Omega(rad/s)\tReal(-)\tImag(-)\tGain(dB)\tPhase(deg)" << endl;

    // 计算指定频率区间幅相特性 0.01~1000 rad/s
    vector<double> omega, L;

    L = Basic::linearSpace(0.01, 0.099, 98);
    omega.insert(omega.end(), L.begin(), L.end());
    L = Basic::linearSpace(0.1, 0.99, 98);
    omega.insert(omega.end(), L.begin(), L.end());
    L = Basic::linearSpace(1.0, 9.8, 89);
    omega.insert(omega.end(), L.begin(), L.end());
    L = Basic::linearSpace(10.0, 98.0, 89);
    omega.insert(omega.end(), L.begin(), L.end());
    L = Basic::linearSpace(100.0, 990.0, 89);
    omega.insert(omega.end(), L.begin(), L.end());
    L = Basic::linearSpace(1000.0, 9900.0, 89);
    omega.insert(omega.end(), L.begin(), L.end());

    for (int n = 0; n < omega.size(); n++)
    {
        double w, a, p, gain, phase;

        // 计算指定频率对应的 幅值 - / 相角 deg
        w = omega[n];
        Go.response(w, a, p);

        // 单位制换算 幅值 dB / 相位 deg
        gain = 20 * log10(a);
        phase = p;

        stream << w << "\t" << a * cos(p / RAD_TO_DEG) << "\t" << a * sin(p / RAD_TO_DEG) << "\t" << gain << "\t" << phase << endl;
    }

    stream.close();

    // 计算开环传递函数的对数频率特性
    vector<double> gain, phase;

    // 默认计算频率区间 0.01~100 rad/s
    omega.clear();
    TransferFunction::bode(Go, omega, gain, phase);

    // 记录仿真结果
    stream.open("Example9B.txt");
    stream << "Omega(rad/s)\tGain(dB)\tPhase(deg)" << endl;

    for (int n = 0; n < omega.size(); n++)
    {
        stream << omega[n] << "\t" << gain[n] << "\t" << phase[n] << endl;
    }

    stream.close();

    // 计算开环传递函数的幅值/相位裕度
    TransferFunction::Margin SF;

    // 计算幅值/相位裕度
    SF = TransferFunction::margin(omega, gain, phase);

    cout << "稳定裕度指标 Margin" << endl;
    cout << "Gm(dB)\t" << SF.Gm << endl;
    cout << "Pm(deg)\t" << SF.Pm << endl;
    cout << "Wcg(rad/s)\t" << SF.Wcg << endl;
    cout << "Wcp(rad/s)\t" << SF.Wcp << endl;
    cout << endl;
}

// 5.15 经典控制回路设计案例
void Example::Example10(void)
{
    cout << "------ 5.15 经典姿态控制回路设计案例 ------" << endl
         << endl;

    // 数据记录文件
    ofstream stream;

    // 动力学系数
    double a22 = 0.0, a24 = 25.49, a25 = 6.98, a34 = 0.07, a35 = 0.0;

    // 环节参数
    double Ta = 0.01, Xa = 0.7, Ts = 0.003, Xs = 0.7;

    // 控制参数
    double Kp = 39.0, Ki = 0.0, Kd = 3.0;

    // 创建环节传递函数
    Polynomial num, den;
    TransferFunction Ga, Gw, Gs;

    num = Polynomial{a25 * a34 - a24 * a35, a25};
    den = Polynomial{a24 + a22 * a34, a22 + a34, 1.0};
    Gw = TransferFunction(num, den);

    num = Polynomial{1.0};
    den = Polynomial{1.0, 2 * Xa * Ta, Ta * Ta};
    Ga = TransferFunction(num, den);

    num = Polynomial{1.0};
    den = Polynomial{1.0, 2 * Xs * Ts, Ts * Ts};
    Gs = TransferFunction(num, den);

    // 计算等效前向通路/反馈支路
    TransferFunction G, H;

    G = Ga * Gw * TransferFunction::element(TransferFunction::Integrator) * Kp;
    H = (TransferFunction::element(TransferFunction::Derivative) * Gs * (Kd / Kp)) + 1.0;

    // 计算系统开环传递函数
    TransferFunction Go;

    Go = G * H;
    Go.minReal();

    cout << "开环传递函数 Go" << endl
         << endl;
    cout << Go << endl;

    // 计算开环传递函数的对数频率特性
    vector<double> omega, gain, phase;

    // 默认计算频率区间 0.01~100 rad/s
    omega.clear();
    TransferFunction::bode(Go, omega, gain, phase);

    // 记录仿真结果
    stream.open("Example10A.txt");
    stream << "Omega(rad/s)\tGain(dB)\tPhase(deg)" << endl;

    for (int n = 0; n < omega.size(); n++)
    {
        stream << omega[n] << "\t" << gain[n] << "\t" << phase[n] << endl;
    }

    stream.close();

    // 计算开环传递函数的幅值/相位裕度
    TransferFunction::Margin SF;

    // 计算幅值/相位裕度
    SF = TransferFunction::margin(omega, gain, phase);

    cout << "稳定裕度指标 Margin" << endl;
    cout << "Gm(dB)\t" << SF.Gm << endl;
    cout << "Pm(deg)\t" << SF.Pm << endl;
    cout << "Wcg(rad/s)\t" << SF.Wcg << endl;
    cout << "Wcp(rad/s)\t" << SF.Wcp << endl;
    cout << endl;

    // 计算系统开环传递函数
    TransferFunction Gc;

    Gc = TransferFunction::feedback(G, H);
    Gc.minReal();

    cout << "闭环传递函数 Gc" << endl
         << endl;
    cout << Gc << endl;

    // 计算闭环系统的单位阶跃响应 0~10s
    vector<double> time, value;

    TransferFunction::step(Gc, time, value);

    // 记录仿真结果
    stream.open("Example10B.txt");
    stream << "Time(s)\tValue(-)" << endl;

    for (int n = 0; n < time.size(); n++)
    {
        stream << time[n] << "\t" << value[n] << endl;
    }

    stream.close();

    // 计算系统的时域性能指标
    TransferFunction::Step ST;

    ST = TransferFunction::step(time, value);

    cout << "动态性能指标 Step" << endl;
    cout << "RiseTime(s)\t" << ST.riseTime << endl;
    cout << "PeakTime(s)\t" << ST.peakTime << endl;
    cout << "SettingTime(s)\t" << ST.settingTime << endl;
    cout << "PeakValue(-)\t" << ST.peakValue << endl;
    cout << "FinalValue(-)\t" << ST.finalValue << endl;
    cout << "OverShoot(-)\t" << ST.overShoot << endl;
    cout << endl;
}

// 7 无人飞行器仿真应用案例
void Example::Example11(void)
{
    cout << "------ 7 无人飞行器仿真应用案例 ------" << endl
         << endl;

    // 自定义仿真工程
    UAVSimulation simulation;

    // 仿真准备流程
    simulation.setup();

    // 仿真初始化流程
    simulation.initialize();

    // 仿真单步运行流程
    simulation.step();
}
